package com.yidu.comment;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 灏嗗璞¤浆鎹负json鏍煎紡
 * @author chensituo
 * @date 2018骞�8鏈�30鏃� 涓嬪崍9:20:28
 */
public class WriterJson {

	
	/**
	 * 灏嗘棩鏈熺被鍨嬭浆鎹㈠瓧绗︾被鍨�
	 * @param date
	 * @return
	 */
	public static String dateToString(Date date){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		if(date==null){
			return "" ;
		}else{
			String str = sdf.format(date);
			return str ;
		}
	}
	/**
	 * 灏嗗瓧绗︿覆杞崲涓篋ate,娌℃湁鏃跺垎绉�
	 * @param date
	 * @return
	 * @throws ParseException 
	 */
	public static Date stringToDate(String date) throws ParseException{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		if(date==null){
			return null ;
		}else{
			Date str = sdf.parse(date);
			return str ;
		}
	}
	
	/**
	 * 鍒ゆ柇瀛楃涓叉槸鍚︿负绌�
	 * @param str
	 * @return
	 */
	public static boolean isEmpty(String str){
		if(str==null) return true ;
		if("".equals(str)) return true ;
		return false ;
	}
}
